package joymouse.logger;

import java.io.PrintStream;

/**
 *
 * @author Ben Wolsieffer
 */
public class SystemIOLogger extends Logger {

    private PrintStream[] streams = {System.out, // Info
        System.err, // Warning
        System.err // Error
    };

    /**
     * Logs the specified {@link Loggable} to standard IO. Info and warning
     * message go to {@code System.out}, while errors are sent to
     * {@code System.err}.
     *
     * @param msg the {@code Loggable} to log
     */
    @Override
    public void log(Loggable msg) {
        int level = msg.getLevel();
        if (level >= 0) {
            if (level < 3) {
                msg.log(streams[level]);
            } else {
                msg.log(streams[2]);
            }
        }
    }
}
